Use time crate directly to get the year
authorJ. Ryan Stinnett <jryans@gmail.com>
Mon, 6 Mar 2017 17:40:39 +0000 (11:40 -0600)
committerJ. Ryan Stinnett <jryans@gmail.com>
Mon, 6 Mar 2017 17:41:19 +0000 (11:41 -0600)
Cargo.lock
Cargo.toml
src/cargo/lib.rs
src/cargo/ops/cargo_new.rs
tests/new.rs

index d7ef7624f52120ff836960a49b02146386ef4ac4..50266e14061f39e5f56463c55f35d303b551b3ca 100644 (file)
@@ -5,7 +5,6 @@ dependencies = [
  "advapi32-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "bufstream 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
  "cargotest 0.1.0",
- "chrono 0.2.25 (registry+https://github.com/rust-lang/crates.io-index)",
  "crates-io 0.7.0",
  "crossbeam 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)",
  "curl 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -37,6 +36,7 @@ dependencies = [
  "tar 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)",
  "tempdir 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
  "term 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)",
+ "time 0.1.36 (registry+https://github.com/rust-lang/crates.io-index)",
  "toml 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "url 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -105,15 +105,6 @@ name = "cfg-if"
 version = "0.1.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 
-[[package]]
-name = "chrono"
-version = "0.2.25"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-dependencies = [
- "num 0.1.36 (registry+https://github.com/rust-lang/crates.io-index)",
- "time 0.1.36 (registry+https://github.com/rust-lang/crates.io-index)",
-]
-
 [[package]]
 name = "cmake"
 version = "0.1.20"
@@ -850,7 +841,6 @@ dependencies = [
 "checksum bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "aad18937a628ec6abcd26d1489012cc0e18c21798210f491af69ded9b881106d"
 "checksum bufstream 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7b48dbe2ff0e98fa2f03377d204a9637d3c9816cd431bfe05a8abbd0ea11d074"
 "checksum cfg-if 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "de1e760d7b6535af4241fca8bd8adf68e2e7edacc6b29f5d399050c5e48cf88c"
-"checksum chrono 0.2.25 (registry+https://github.com/rust-lang/crates.io-index)" = "9213f7cd7c27e95c2b57c49f0e69b1ea65b27138da84a170133fd21b07659c00"
 "checksum cmake 0.1.20 (registry+https://github.com/rust-lang/crates.io-index)" = "a3a6805df695087e7c1bcd9a82e03ad6fb864c8e67ac41b1348229ce5b7f0407"
 "checksum crossbeam 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)" = "0c5ea215664ca264da8a9d9c3be80d2eaf30923c259d03e870388eb927508f97"
 "checksum curl 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c90e1240ef340dd4027ade439e5c7c2064dd9dc652682117bd50d1486a3add7b"
index 92257587257502c19eeb2af37fad0dbc78703e96..bed515a48112c2f63426526ebdc8354cf48aa003 100644 (file)
@@ -17,7 +17,6 @@ name = "cargo"
 path = "src/cargo/lib.rs"
 
 [dependencies]
-chrono = "0.2.25"
 crates-io = { path = "src/crates-io", version = "0.7" }
 crossbeam = "0.2"
 curl = "0.4.6"
@@ -44,6 +43,7 @@ shell-escape = "0.1"
 tar = { version = "0.4", default-features = false }
 tempdir = "0.3"
 term = "0.4.4"
+time = "0.1.36"
 toml = "0.3"
 url = "1.1"
 
index fe11b4e7e56e9d977fdd8c90cace06d3af787460..0d4d072fc30b0eb1611efcdbd23abb513d7c1ee2 100755 (executable)
@@ -5,7 +5,6 @@
 #[macro_use] extern crate log;
 #[macro_use] extern crate serde_derive;
 #[macro_use] extern crate serde_json;
-extern crate chrono;
 extern crate crates_io as registry;
 extern crate crossbeam;
 extern crate curl;
@@ -27,6 +26,7 @@ extern crate shell_escape;
 extern crate tar;
 extern crate tempdir;
 extern crate term;
+extern crate time;
 extern crate toml;
 extern crate url;
 
index f5950964a0869131761d3c18a1b8a437dc03552b..6f6a7b67238d86b10ffb658ef9a362b3dcd4de21 100644 (file)
@@ -8,9 +8,9 @@ use git2::Config as GitConfig;
 
 use term::color::BLACK;
 
-use chrono::{Datelike,Local};
 use handlebars::{Handlebars, no_escape};
 use tempdir::TempDir;
+use time;
 use toml;
 
 use core::Workspace;
@@ -521,7 +521,7 @@ fn mk(config: &Config, opts: &MkOptions) -> CargoResult<()> {
     let mut data = BTreeMap::new();
     data.insert("name".to_owned(), name.to_owned());
     data.insert("author".to_owned(), author);
-    data.insert("year".to_owned(), Local::now().year().to_string());
+    data.insert("year".to_owned(), (time::now().tm_year + 1900).to_string());
 
     let template_set = try!(get_input_template(config, opts));
     for template in template_set.template_files.iter() {
index 9ddedc420d9561c34ed33b7262d6743103dd9457..7a4532520a7bd363233e94ec38566f4d46cee2b2 100644 (file)
@@ -1,8 +1,8 @@
 extern crate cargo;
 extern crate cargotest;
-extern crate chrono;
 extern crate hamcrest;
 extern crate tempdir;
+extern crate time;
 
 use std::fs::{self, File};
 use std::io::prelude::*;
@@ -11,7 +11,6 @@ use std::env;
 use cargo::util::ProcessBuilder;
 use cargotest::process;
 use cargotest::support::{execs, git, paths};
-use chrono::{Datelike,Local};
 use hamcrest::{assert_that, existing_file, existing_dir, is_not};
 use tempdir::TempDir;
 
@@ -95,7 +94,8 @@ fn main () {
     let license = paths::root().join("foo/LICENSE");
     let mut contents = String::new();
     File::open(&license).unwrap().read_to_string(&mut contents).unwrap();
-    assert!(contents.contains(&format!("(c) {} {}", Local::now().year(), "foo")));
+    let expected = format!("(c) {} {}", (time::now().tm_year + 1900).to_string(), "foo");
+    assert!(contents.contains(&expected));
 
     assert_that(cargo_process("build").cwd(&paths::root().join("foo")),
                 execs().with_status(0));